Skip to content

Conversation

@FinnIckler
Copy link
Member

I think this is a good comprise between a full table for locks and quits?

@FinnIckler
Copy link
Member Author

Ok, I think the logic is correct now


scope :not_empty, -> { where.not(best: 0) }

scope :without_quitters, -> { where(quit_by_id: nil).or(where.not(best: 0)) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case do you need the second or(where.not(best: 0)) part?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sidenote: .or(not_empty) should work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do still want to show quitters for previous rounds.
Currently when someone is quit from round 2 who advanced from round 1 I mark them as quit in round 2 and 1, but I still want to show them in round 1. There is a case to be made to only mark them as quit in round 1 as those results will already be locked so only flipping the advancing will be necessary?

Comment on lines +47 to +49
has_many :live_results_without_quitters,
-> { without_quitters.order(:global_pos) },
class_name: "LiveResult"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it feels like this shouldn't be a separate relation. Why does some_round.live_results.without_quitters (ie, applying the without_quitters scope to the live_results relation) not work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I use it in a scope one line down in the
has_many :live_competitors, through: :live_results_without_quitters, source: :registration

Comment on lines +189 to +190
init_round
return 0 if number == 1 || linked_round.present?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you ignoring the return value of init_round? And what does the return value 0 represent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value is how many results where locked and it's 0 if there is no previous round to lock


def open_and_lock_previous(current_user)
init_round
return 0 if number == 1 || linked_round.present?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you returning early in case of a linked round? The linked round's individual rounds would all need to be locked, and returning early feels a bit premature...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is about locking the previous round as the title suggests. Linked Rounds do not have previous rounds


result.mark_as_quit(current_user)

return 1 if number == 1 || linked_round.present?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this return value represent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how many results have been marked as quit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants